package com.dom.stor.dao.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.dom.stor.dao.entity.TOrganInfo;
import com.dom.stor.dao.mapper.TOrganInfoMapper;
import com.dom.stor.dao.service.ITOrganInfoService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * <p>
 * B_组织机构信息表 服务实现类
 * </p>
 *
 * @author xllei
 * @since 2018-11-17
 */
@Service
public class TOrganInfoServiceImpl extends ServiceImpl<TOrganInfoMapper, TOrganInfo> implements ITOrganInfoService {

    @Override
    public Map<Integer, String> getOrganNameList(Integer memCode) {
        List<TOrganInfo> organInfos = getOrganList(memCode);
        return organInfos.stream().collect(Collectors.toMap(TOrganInfo::getId, entity->{return entity.getOrganName();}));
    }

    private List<TOrganInfo> getOrganList(Integer memCode) {
        Wrapper<TOrganInfo> wrapper = new EntityWrapper<>();
        wrapper.eq("mem_code", memCode);
        return this.selectList(wrapper);
    }
}
